const Controller = require('../core/base_controller');
// const mock = require('mockjs')
// const {list} = mock.mock({
//   'list|300': [
//     {
//       title: "@ctitle(10,20)",
//       "price|1-1000":1,
//       image: "https://unsplash.it/400/800/?@name"
//     }
//   ]
// })
// list.forEach(item => {
//   app.mysql.insert('shops',item)
// })
class HomeController extends Controller {
  async getList() {
    const {ctx,app} = this;
    try{
      const data = await ctx.service.shop.getList()
      if(typeof data === 'string') {
        this.error(data)
      } else {
        this.success(data)
      }
    } catch(err) {
      this.error(err.message)
    }
  }
  async getDetail() {
    const {ctx,app} = this;
    try{
      const data = await ctx.service.shop.getDetail()
      if(typeof data === 'string') {
        this.error(data)
      } else {
        this.success(data)
      }
    } catch(err) {
      this.error(err.message)
    }
  }
}

module.exports = HomeController;